'20100301
Imports System.io
Imports System.Threading
Public Class FileControl
    Private root As DirectoryInfo
    Private allDirectories As DirectoryInfo()
    Private allFile As FileInfo()
    Private ProtectFileNameList As New List(Of String)
    Private deleteTargetFile As String
    Sub New()
        root = New DirectoryInfo(Directory.GetCurrentDirectory())
        getNewFileAndNewDirectories()

    End Sub
    Sub New(ByVal rootPath As String)
        root = New DirectoryInfo(rootPath)
        getNewFileAndNewDirectories()

    End Sub
    Function SearchFileName() As String()


        Return Nothing
    End Function
    Function SearchDirectoryName() As String()

        Return Nothing
    End Function
    Sub killAllFile()
        getNewFileAndNewDirectories()
        Dim allFileNameList As New List(Of FileInfo)
        For Each killFileinfo As FileInfo In allFile
            If isProtectFile(killFileinfo.Name) Then
            Else
                allFileNameList.Add(killFileinfo)
            End If

        Next
        For Each killFileinfo As FileInfo In allFileNameList
            If killFileinfo.Exists Then
                Console.WriteLine(killFileinfo.Name)
                killFileinfo.Delete()
            End If
        Next
    End Sub
    Sub killAllFile(ByVal subname As String)
        getNewFileAndNewDirectories(subname)
        Dim allFileNameList As New List(Of FileInfo)
        For Each killFileinfo As FileInfo In allFile
            If isProtectFile(killFileinfo.Name) Then
            Else
                allFileNameList.Add(killFileinfo)
            End If

        Next
        For Each killFileinfo As FileInfo In allFileNameList
            If killFileinfo.Exists Then
                Console.WriteLine(killFileinfo.Name)
                killFileinfo.Delete()
            End If
        Next
    End Sub

    Sub setProtectFileNameArray(ByVal nameArray() As String)
        ProtectFileNameList.Clear()
        For Each fileName As String In nameArray
            ProtectFileNameList.Add(fileName)
        Next
    End Sub
    Sub setProtectFileName(ByVal fileName As String)

        ProtectFileNameList.Add(fileName)

    End Sub
    Sub clearProtectFileName()
        ProtectFileNameList.Clear()
    End Sub
    Sub getNewFileAndNewDirectories()
        allFile = root.GetFiles
        allDirectories = root.GetDirectories
        GC.Collect()
    End Sub
    Sub getNewFileAndNewDirectories(ByVal subname As String)
        allFile = root.GetFiles("*." + subname)
        allDirectories = root.GetDirectories(subname + "*")
        GC.Collect()
    End Sub
    Function isProtectFile(ByVal fileName As String) As Boolean
        Dim resBoolean As Boolean = False
        For Each ProtectFileName As String In ProtectFileNameList
            If ProtectFileName = fileName Then
                resBoolean = True
                Exit For
            End If
        Next
        Return resBoolean
    End Function

    Sub createDeleteFileThread(ByVal FileName As String)
        deleteTargetFile = FileName
    End Sub
    Sub deleteFileThread()
        Dim FileName As String = deleteTargetFile
        While True

        End While
    End Sub
    Sub clear()

    End Sub
End Class
